package com.core.family.admin.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import java.util.List;
import java.util.Objects;
import org.springframework.stereotype.Service;
import com.core.family.admin.domain.po.PlatStorageLogic;
import com.core.family.admin.service.PlatStorageLogicService;
import com.core.family.admin.domain.req.PlatStorageLogicReq;
import com.core.common.gen.BaseQuery;
import com.core.common.gen.PageQuery;
import com.core.common.annotation.MenuDesc;
import com.core.common.domain.response.R;
import io.swagger.annotations.Api;
import org.springframework.beans.BeanUtils;




/**
 * @author honglei
 * @version 1.0
 * @time: 2023-6-15 10:13:03
 * @Description 服务实现层 文件逻辑存储
 */
@MenuDesc(desc = "文件逻辑存储", code = "platStorageLogic")
@Api(tags = "PlatStorageLogicController 文件逻辑存储")
@RestController
@RequestMapping("/api/PlatStorageLogic/")
public class PlatStorageLogicController {

    @Autowired
    PlatStorageLogicService service;




    /**
     * 根据id获取详情
     * @param request
     * @param id
     * @return
     */
    @GetMapping(value = "get/{id}")
    public R get(HttpServletRequest request, @PathVariable("id") Long id){
        return R.ok(service.getById(id));
    }


   /**
     * 分页查询
     * @return
     */
    @RequestMapping(value = "getPage",method = {RequestMethod.GET,RequestMethod.POST})
    public R getPage(@RequestBody PageQuery<PlatStorageLogicReq> pageQuery){

        PageQuery<BaseQuery> baseQuery=new PageQuery<>();
        baseQuery.setQueryBean(pageQuery.getQueryBean());
        baseQuery.setPageIndex(pageQuery.getPageIndex());
        baseQuery.setPageSize(pageQuery.getPageSize());
        return R.ok(service.selectPage(baseQuery));
    }
    /**
    * 批量查询
    * @return
    */
    @RequestMapping(value = "getList",method = {RequestMethod.GET,RequestMethod.POST})
    public R getList(@RequestBody PlatStorageLogicReq queryReq){
        return R.ok(service.selectList(queryReq));
    }

    /**
     * 普通更新
     * @param bean
     * @return
     */
    @PostMapping(value = "update")
    public R update(@RequestBody PlatStorageLogic bean){
        return R.ok(service.updateById(bean));
    }


    /**
     * 新增
     * @param bean
     * @return
     */
    @PostMapping(value = "save")
    public R save(@RequestBody PlatStorageLogic bean){
        return R.ok(service.save(bean));
    }

 /**
     * 删除
     * @param request
     * @param id
     * @return
     */
    @PostMapping(value = "del/{id}")
    public R del(HttpServletRequest request, @PathVariable("id") Long id){
        return R.ok(service.removeById(id));
    }

        /**
        * 批量删除
        * @param request
        * @param ids
        * @return
        */
    @PostMapping(value = "batch/del")
    public R batchDel(HttpServletRequest request, @RequestBody List<String> ids ){
            return R.ok(service.removeByIds(ids));
    }


    }
